/*
 * @Description:
 * @Version: 2.0
 * @Autor: wangmiao
 * @Date: 2022-08-25 18:34:42
 * @LastEditors: wangmiao
 * @LastEditTime: 2022-08-26 18:12:15
 */
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import * as path from 'path'

function _resolve(dir: string) {
  return path.resolve(__dirname, dir)
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      '@pages': _resolve('src/pages'),
      '@components': _resolve('src/components'),
      '@assets': _resolve('src/assets'),
      '@store': _resolve('src/store'),
      '@hooks': _resolve('src/hooks'),
    },
  },
  base: './',
  server: {
    open: true,
    proxy: {
      '/api': {
        target: 'https://testripx.iuoooo.com',
        ws: true,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
})
